% Exercise 9
% Michael Sieber, Philipp Rusch

%(1+1)-ES with 1/5 rule
N = 100;
parent = ones(N, 1);
sigma = 1.0;
sigma_stop = 10^-1;
test_func = 'Kugelmodell';
[o_yp, o_sigma_dyn, o_fitness_dyn, o_generations, o_func_calls] = one_plus_one_es(parent, N, sigma, sigma_stop, test_func);

[s_yp, s_sigma_dyn, s_fitness_dyn, s_generations, s_func_calls] = slash_comma_sa_es_intermediate(3, 3, 10, N, test_func, sigma, sigma_stop);

% print the result
clf();
hold on
semilogy(o_generations, o_fitness_dyn, '1');
semilogy(s_generations, s_fitness_dyn, '2');
ylabel("Fitness");
xlabel("Generations");

title("F-Dynamik");
legend("(1+1)-ES with 1/5 rule", "(3/3I, 10)-SA-ES");
legend('boxon');
legend('Location', 'northeast');

disp("(1+1)-ES Function calls");
o_func_calls
disp("(3/3,10)-SA-ES Function calls");
s_func_calls

hold off